package com.example.notelite;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MyAdaper extends BaseAdapter {
    private Context context;
     List<record> recordsList;
    public MyAdaper(Context context,List<record> recordsList){
        this.context=context;
        this.recordsList=recordsList;
    }
    public int getCount(){
        return recordsList==null?0:recordsList.size();
    }
    public Object getItem(int i){
        return recordsList.get(i);
    }
    public long getItemId(int i){
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder viewholder;
        if(convertView==null){
            convertView=LayoutInflater.from(context).inflate(R.layout.cellfactory,parent,false);
            viewholder=new viewHolder(convertView);
            convertView.setTag(viewholder);
        return null;
    }else{
            viewholder=(viewHolder)convertView.getTag();
        }
        record records=recordsList.get(position);
        viewholder.titlecontent.setText(records.getRecords());
        viewholder.create_timelabel.setText(records.getCreat_T());
        return convertView;



    }
    class viewHolder extends RecyclerView.ViewHolder{
        TextView titlecontent;
        TextView create_timelabel;

        public viewHolder(@NonNull View itemView) {
            super(itemView);
            titlecontent=itemView.findViewById(R.id.titlecontent);
            create_timelabel=itemView.findViewById(R.id.cteat_timelabel);

        }
    }


}
